package org.nlp2rdf.navigator.benchmark;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * Created by Claus Stadler
 * Date: Oct 25, 2010
 * Time: 12:17:39 AM
 */
public class ClassifyLimitPhaseReconfigurator
        implements IPhaseReconfigurator
{
    private static final Logger logger = LoggerFactory.getLogger(ClassifyLimitPhaseReconfigurator.class);

    private NkeGenericClassifier classifier;
    private List<Integer> limits;


    public ClassifyLimitPhaseReconfigurator(NkeGenericClassifier classifier, List<Integer> limits)
    {
        this.classifier = classifier;
        this.limits = limits;
    }

    public void reconfigure(int phaseId)
    {
        Integer oldValue = classifier.getLimit();
        Integer newValue = LearningTimePhaseReconfigurator.getValueAtIndexOrLast(limits, phaseId);
        if(newValue != null && !newValue.equals(oldValue)) {
            logger.info("Changing maximum classification limit from " + oldValue + " to " + newValue);
            classifier.setLimit(newValue);
        }
    }
}
